﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace VirtualDeveloper
{
    /// <summary>
    /// sample : D:\SampleCode little *.txt
    /// sample : D:\SampleCode standard *.txt
    /// sample : D:\SampleCode big *.txt
    /// </summary>
    [DebuggerNonUserCode]
    //ncrunch: no coverage start
    public static class Program
    {
        private static void Main(string[] args)
        {
            if (!args.Any() && args.Count() != 2)
            {
                Console.Error.WriteLine("arg directory path and method are mandatories");
                Environment.Exit(-1);
            }
            try
            {
                Run(args);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("error : {0}", e.Message);
                Environment.Exit(-1);
            }
        }

        private static void Run(IList<string> args)
        {
            var directoryPath = args[0];
            var method = args[1];
            var filter = (args.Count() > 2) ? args[2] : "*.cs";

            var workingDeveloper = new WorkingDeveloper(directoryPath, filter);

            switch (method)
            {
                case "little":
                    workingDeveloper.LittleChanges();
                    break;
                case "big":
                    workingDeveloper.BigChanges();
                    break;
                case "standard":
                    workingDeveloper.StandardChanges();
                    break;
                default:
                    Console.Error.WriteLine("method must be little, big or standard");
                    Environment.Exit(-1);
                    break;
            }

            Console.WriteLine("successfull");
            Environment.Exit(0);
        }
    }
    //ncrunch: no coverage end
}
